﻿//-----------------------------------------------------------------------
// <copyright file="MultipleResolutionRuleDescriptor.cs">
//     Copyright (c) Nicole Calinoiu. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

using Microsoft.FxCop.Sdk;
using Microsoft.VisualStudio.CodeAnalysis.Extensibility;

namespace Bordecal.FxCop.Sdk
{
	/// <summary>
	/// Rule descriptor with multiple resolution text patterns.
	/// </summary>
	public class MultipleResolutionRuleDescriptor : RuleDescriptor
	{
		#region Fields

		private readonly IDictionary<string, string> _resolutions;

		#endregion

		#region Constructors

		/// <summary>
		/// Initializes a new instance of the <see cref="MultipleResolutionRuleDescriptor"/> class.
		/// </summary>
		/// <param name="category">The rule category.</param>
		/// <param name="name">The rule name.</param>
		/// <param name="description">The rule description.</param>
		/// <param name="checkId">The rule check ID.</param>
		/// <param name="owner">The rule owner.</param>
		/// <param name="email">The rule support e-mail address.</param>
		/// <param name="url">The rule help URL.</param>
		/// <param name="certainty">The default violation certainty.</param>
		/// <param name="fixCategories">The default fix categories.</param>
		/// <param name="messageLevel">The default message level.</param>
		/// <param name="resolutions">A dictionary of resolution names and text patterns.</param>
		public MultipleResolutionRuleDescriptor(
				string category,
				string name,
				string description,
				string checkId,
				string owner,
				string email,
				Uri url,
				int certainty,
				FixCategories fixCategories,
				MessageLevel messageLevel,
				IDictionary<string, string> resolutions)
			: base(category, name, description, checkId, owner, email, url, certainty, fixCategories, messageLevel)
		{
			if (resolutions == null)
			{
				throw new ArgumentNullException("resolutions");
			}

			this._resolutions = resolutions;
		}

		#endregion

		#region Methods

		/// <summary>
		/// Returns the resolution pattern string for a specified resoution.
		/// </summary>
		/// <param name="name">The resolution pattern name.</param>
		/// <returns>The resolution pattern string.</returns>
		public override string GetResolutionText(string name)
		{
			return this._resolutions[name];
		}

		#endregion
	}
}